<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Choosing a library</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mysqlinfo.api.choosing.html">Choosing an API</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mysqlinfo.concepts.html">Concepts</a></div>
 <div class="up"><a href="mysql.html">Overview of the MySQL PHP drivers</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mysqlinfo.library.choosing" class="chapter">
   <h1>Choosing a library</h1>

   <p class="para">
    The mysqli, PDO_MySQL and mysql PHP extensions are lightweight wrappers on
    top of a C client library. The extensions can either use the
    <a href="book.mysqlnd.html" class="link">mysqlnd</a> library or the <em>libmysqlclient</em>
    library. Choosing a library is a compile time decision.
   </p>
   <p class="para">
    The mysqlnd library is part of the PHP distribution since 5.3.0. It offers
    features like lazy connections and query caching, features that are not available
    with libmysqlclient, so using the built-in mysqlnd library is highly recommended.
    See the <a href="book.mysqlnd.html" class="link">mysqlnd documentation</a> for
    additional details, and a listing of features and functionality that it offers.
   </p>
   <p class="para">
    <div class="example" id="example-1524">
     <p><strong>Example #1 Configure commands for using mysqlnd or libmysqlclient</strong></p>
     <div class="example-contents">
<div class="shellcode"><pre class="shellcode">// Recommended, compiles with mysqlnd
$ ./configure --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-mysql=mysqlnd

// Not recommended, compiles with libmysqlclient
$ ./configure --with-mysqli=/path/to/mysql_config --with-pdo-mysql=/path/to/mysql_config --with-mysql=/path/to/mysql_config</pre>
</div>
     </div>

    </div>
   </p>
   <p class="para">
    <em class="emphasis">Library feature comparison</em>
   </p>
   <p class="para">
    It is recommended to use the <a href="book.mysqlnd.html" class="link">mysqlnd</a>
    library instead of the MySQL Client Server library (libmysqlclient). Both
    libraries are supported and constantly being improved.
   </p>
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th class="empty">&nbsp;</th>
       <th>MySQL native driver (<a href="book.mysqlnd.html" class="link">mysqlnd</a>)</th>
       <th>MySQL client server library (<em>libmysqlclient</em>)</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>Part of the PHP distribution</td>
       <td>Yes</td>
       <td>No</td>
      </tr>

      <tr>
       <td>PHP version introduced</td>
       <td>5.3.0</td>
       <td>N/A</td>
      </tr>

      <tr>
       <td>License</td>
       <td>PHP License 3.01</td>
       <td>Dual-License</td>
      </tr>

      <tr>
       <td>Development status</td>
       <td>Active</td>
       <td>Active</td>
      </tr>

      <tr>
       <td>Lifecycle</td>
       <td>No end announced</td>
       <td>No end announced</td>
      </tr>

      <tr>
       <td>PHP 5.4 compile default (for all MySQL extensions)</td>
       <td>Yes</td>
       <td>No</td>
      </tr>

      <tr>
       <td>PHP 5.3 compile default (for all MySQL extensions)</td>
       <td>No</td>
       <td>Yes</td>
      </tr>

      <tr>
       <td>Compression protocol support</td>
       <td>Yes (5.3.1+)</td>
       <td>Yes</td>
      </tr>

      <tr>
       <td>SSL support</td>
       <td>Yes (5.3.3+)</td>
       <td>Yes</td>
      </tr>

      <tr>
       <td>Named pipe support</td>
       <td>Yes (5.3.4+)</td>
       <td>Yes</td>
      </tr>

      <tr>
       <td>Non-blocking, asynchronous queries</td>
       <td>Yes</td>
       <td>No</td>
      </tr>

      <tr>
       <td>Performance statistics</td>
       <td>Yes</td>
       <td>No</td>
      </tr>

      <tr>
       <td>LOAD LOCAL INFILE respects the <a href="ini.core.html#ini.open-basedir" class="link">open_basedir directive</a></td>
       <td>Yes</td>
       <td>No</td>
      </tr>

      <tr>
       <td>Uses PHP&#039;s native memory management system (e.g., follows PHP memory limits)</td>
       <td>Yes</td>
       <td>No</td>
      </tr>

      <tr>
       <td>Return numeric column as double (COM_QUERY)</td>
       <td>Yes</td>
       <td>No</td>
      </tr>

      <tr>
       <td>Return numeric column as string (COM_QUERY)</td>
       <td>Yes</td>
       <td>Yes</td>
      </tr>

      <tr>
       <td>Plugin API</td>
       <td>Yes</td>
       <td>Limited</td>
      </tr>

      <tr>
       <td>Read/Write splitting for MySQL Replication</td>
       <td>Yes, with plugin</td>
       <td>No</td>
      </tr>

      <tr>
       <td>Load Balancing</td>
       <td>Yes, with plugin</td>
       <td>No</td>
      </tr>

      <tr>
       <td>Fail over</td>
       <td>Yes, with plugin</td>
       <td>No</td>
      </tr>

      <tr>
       <td>Lazy connections</td>
       <td>Yes, with plugin</td>
       <td>No</td>
      </tr>

      <tr>
       <td>Query caching</td>
       <td>Yes, with plugin</td>
       <td>No</td>
      </tr>

      <tr>
       <td>Transparent query manipulations (E.g., auto-EXPLAIN or monitoring)</td>
       <td>Yes, with plugin</td>
       <td>No</td>
      </tr>

     </tbody>
    
   </table>

  </div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mysqlinfo.api.choosing.html">Choosing an API</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mysqlinfo.concepts.html">Concepts</a></div>
 <div class="up"><a href="mysql.html">Overview of the MySQL PHP drivers</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
